import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

public class JedisClusterDemo {

    public static void main(String[] args) {
        Set<HostAndPort> nodes = new HashSet<>();
        nodes.add(new HostAndPort("172.30.0.101", 6379));
        nodes.add(new HostAndPort("172.30.0.102", 6379));
        nodes.add(new HostAndPort("172.30.0.103", 6379));
        nodes.add(new HostAndPort("172.30.0.104", 6379));
        nodes.add(new HostAndPort("172.30.0.105", 6379));
        nodes.add(new HostAndPort("172.30.0.106", 6379));
        nodes.add(new HostAndPort("172.30.0.107", 6379));
        nodes.add(new HostAndPort("172.30.0.108", 6379));
        nodes.add(new HostAndPort("172.30.0.109", 6379));

        try (JedisCluster jedisCluster = new JedisCluster(nodes)) {
            jedisCluster.set("k1", "111");
            String val = jedisCluster.get("k1");
            System.out.println("k1: " + val);
        }

    }

}
